wpt_tmp_queued = 0;
}
-#if NEW_STRINGS
void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->shortname = args;
}
-#else
-void wpt_name(xg_string args, const QXmlStreamAttributes* unused)
-{
- if (args) {
- wpt_tmp->shortname = xstrdup(args);
- }
-}
-#endif
-#if NEW_STRINGS
void wpt_desc(const QString& args, const QXmlStreamAttributes* unused)
{
wpt_tmp->description += args.trimmed();
}
-#else
-void wpt_desc(xg_string args, const QXmlStreamAttributes* unused)
-{
- if (args) {
- char* tmp, *c;
-
- tmp = xstrdup((char*)args);
- c = lrtrim(tmp);
- if (*c) {
- wpt_tmp->description = xstrappend(wpt_tmp->description, c);
- }
- xfree(tmp);
- }
-}
-#endif
void wpt_time(xg_string args, const QXmlStreamAttributes* unused)
{
wpt_tmp->SetCreationTime(xml_parse_time(args));
}
-#if NEW_STRINGS
void wpt_coord(const QString& args, const QXmlStreamAttributes* attrv)
-#else
-void wpt_coord(xg_string args, const QXmlStreamAttributes* attrv)
-#endif
{
int n = 0;
double lat, lon, alt;
int n = 0;
route_head* trk_head = route_head_alloc();
-#if NEW_STRINGS
+
QString iargs = args;
if (!wpt_tmp->shortname.isEmpty()) {
-#else
- if (wpt_tmp->shortname) {
-#endif
- trk_head->rte_name = xstrdup(wpt_tmp->shortname);
+ trk_head->rte_name = wpt_tmp->shortname;
}
track_add_head(trk_head);
-#if NEW_STRINGS
while ((n = sscanf(CSTR(iargs), "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
-#else
- while ((n = sscanf(args, "%lf,%lf,%lf%n", &lon, &lat, &alt, &consumed)) > 0) {
-#endif
-
trkpt = waypt_new();
trkpt->latitude = lat;
trkpt->longitude = lon;
}
track_add_wpt(trk_head, trkpt);
-#if NEW_STRINGS
iargs = iargs.mid(consumed);
-#else
- args += consumed;
-#endif
}
}
writer->writeStartElement("description");
hwriter.writeStartElement("table");
-#if NEW_STRINGS
if (!header->rte_desc.isEmpty()) {
-#else
- if (header->rte_desc) {
-#endif
kml_td(hwriter, "Description", QString(" %1 ").arg(header->rte_desc));
}
kml_td(hwriter, "Distance", QString(" %1 %2 ").arg(QString::number(distance, 'f', 1)).arg(distance_units));
if (export_points) {
writer->writeStartElement("Placemark");
if (atoi(opt_labels)) {
-#if NEW_STRINGS
writer->writeOptionalTextElement("name", waypointp->shortname);
-#else
- writer->writeOptionalTextElement("name", QString::fromUtf8(waypointp->shortname));
-#endif
}
writer->writeEmptyElement("snippet");
kml_output_description(waypointp);
writer->writeEndElement(); // Close Style tag
writer->writeStartElement("ExtendedData");
-#if NEW_STRINGS
if (!waypointp->shortname.isEmpty()) {
-#else
- if (waypointp->shortname) {
-#endif
-
kml_write_data_element("gc_num", waypointp->shortname);
}
writer->writeTextElement("description", link.url_);
}
} else {
-#if NEW_STRINGS
if (waypointp->shortname != waypointp->description) {
-#else
- if (strcmp(waypointp->shortname, waypointp->description)) {
-#endif
writer->writeOptionalTextElement("description", waypointp->description);
}
}
}
/* We want our waypoint to have a name, but not our trackpoint */
-#if NEW_STRINGS
if (wpt->shortname.isEmpty()) {
-#else
- if (!wpt->shortname) {
-#endif
if (wpt->fix == fix_none) {
- wpt->shortname = xstrdup("ESTIMATED Position");
+ wpt->shortname = "ESTIMATED Position";
} else {
- wpt->shortname = xstrdup("Position");
+ wpt->shortname = "Position";
}
}
switch (wpt->fix) {
case fix_none:
-#if NEW_STRINGS
wpt->shortname = "ESTIMATED Position";
-#else
- if (wpt->shortname) {
- xfree(wpt->shortname);
- }
- wpt->shortname = xstrdup("ESTIMATED Position");
-#endif
break;
case fix_unknown:
break;
if (a.hasAttribute("cache_id")) {
int n = a.value("cache_id").toString().toInt();
QString fn = QString("N%1").arg(n, 5, 16, QChar('0'));
- wpt_tmp->shortname = xstrdup(fn);
+ wpt_tmp->shortname = fn;
UrlLink l(QString(NC_URL) + QString::number(n));
wpt_tmp->AddUrlLink(l);
}
if (a.hasAttribute("name")) {
- wpt_tmp->description = xstrdup(a.value("name").toString());
+ wpt_tmp->description = a.value("name").toString();
}
if (a.hasAttribute("user_name")) {
gc_data->placer = a.value("user_name").toString();
str = osm_strip_html(value);
if (strcmp(key, "name") == 0) {
-#if NEW_STRINGS
if (wpt->shortname.isEmpty()) {
wpt->shortname = str;
}
-#else
- if (! wpt->shortname) {
- wpt->shortname = xstrdup(str);
- }
-#endif
} else if (strcmp(key, "name:en") == 0) {
-#if NEW_STRINGS
wpt->shortname = str;
-#else
- if (wpt->shortname) {
- xfree(wpt->shortname);
- }
- wpt->shortname = xstrdup(str);
-#endif
} else if ((ikey = osm_feature_ikey(key)) >= 0) {
char* id = osm_feature_symbol(ikey, value);
wpt->icon_descr = id;
xfree(id);
}
} else if (strcmp(key, "note") == 0) {
-#if NEW_STRINGS
if (wpt->notes.isEmpty()) {
wpt->notes = str;
} else {
wpt->notes += "; ";
wpt->notes += str;
}
-#else
- if (wpt->notes) {
- char* tmp;
- xasprintf(&tmp, "%s; %s", CSTRc(wpt->notes), str);
- xfree(wpt->notes);
- wpt->notes = tmp;
- } else {
- wpt->notes = xstrdup(str);
- }
-#endif
} else if (strcmp(key, "gps:hdop") == 0) {
wpt->hdop = atof(str);
} else if (strcmp(key, "gps:vdop") == 0) {
str = osm_strip_html(value);
if (strcmp(key, "name") == 0) {
-#if NEW_STRINGS
if (rte->rte_name.isEmpty()) {
rte->rte_name = str;
}
-#else
- if (! rte->rte_name) {
- rte->rte_name = xstrdup(str);
- }
-#endif
} else if (strcmp(key, "name:en") == 0) {
-#if NEW_STRINGS
rte->rte_name = str;
-#else
- if (rte->rte_name) {
- xfree(rte->rte_name);
- }
- rte->rte_name = xstrdup(str);
-#endif
}
xfree(str);
route_head* track;
track = route_head_alloc();
- track->rte_name = xstrdup("SkyTraq tracklog");
- track->rte_desc = xstrdup("SkyTraq GPS tracklog data");
+ track->rte_name = "SkyTraq tracklog";
+ track->rte_desc = "SkyTraq GPS tracklog data";
track_add_head(track);
pst->route_head_ = track;
if (trackno > 1) {
xasprintf(&track->rte_name, "%s (%d)", CSTR(rte_name), trackno);
} else {
- track->rte_name = xstrdup(rte_name);
+ track->rte_name = rte_name;
}
}
if (rte_desc != NULL) {
- track->rte_desc = xstrdup(rte_desc);
+ track->rte_desc = rte_desc;
}
}
track_add_wpt(track, wpt);
wpt_tmp->longitude = lon;
wpt_tmp->latitude = lat;
- wpt_tmp->description = xstrdup(desc);
+ wpt_tmp->description = desc;
wpt_tmp->shortname = mkshort(mkshort_handle, desc);
waypt_add(wpt_tmp);
*/
waypoint* tmp = new waypoint;
*tmp = *wpt;
-#if NEW_STRINGS
-#else
- if (wpt->shortname) {
- tmp->shortname = xstrdup(wpt->shortname);
- }
- if (wpt->description) {
- tmp->description = xstrdup(wpt->description);
- }
- if (wpt->notes) {
- tmp->notes = xstrdup(wpt->notes);
- }
-#endif
tmp->icon_descr = wpt->icon_descr;
* try to be sure that we have these fields even if just by
* copying them from elsewhere.
*/
-#if NEW_STRINGS
+
// Note tests for isNull here as some formats intentionally set "".
// This is kind of goofy, but it emulates the C string implementation.
if (wpt->shortname.isNull()) {
wpt->shortname = QString("WPT%1").arg(n);
}
}
-#else
- if (wpt->shortname == NULL) {
- if (wpt->description) {
- wpt->shortname = xstrdup(wpt->description);
- } else if (wpt->notes) {
- wpt->shortname = xstrdup(wpt->notes);
- } else {
- /* Last ditch: make up a name */
- char *sn;
- xasprintf(&sn, "WPT%03d", waypt_ct);
- wpt->shortname = sn;
- }
- }
-#endif
-#if NEW_STRINGS
if (wpt->description.isEmpty()) {
if (!wpt->notes.isNull()) {
wpt->description = wpt->notes;
}
}
}
-#else
- if (wpt->description == NULL || strlen(wpt->description) == 0) {
- if (wpt->description) {
- xfree(wpt->description);
- }
- if (wpt->notes != NULL) {
- wpt->description = xstrdup(wpt->notes);
- } else {
- if (wpt->shortname != NULL) {
- wpt->description = xstrdup(wpt->shortname);
- }
- }
- }
-#endif
update_common_traits(wpt);
/*
* This and waypt_dupe should be closely synced.
*/
-#if NEW_STRINGS
-#else
- if (wpt->shortname) {
- xfree(wpt->shortname);
- }
- if (wpt->description) {
- xfree(wpt->description);
- }
- if (wpt->notes) {
- xfree(wpt->notes);
- }
-#endif
if (wpt->gc_data != &empty_gc_data) {
geocache_data* gc_data = (geocache_data*)wpt->gc_data;
if (attrv->hasAttribute("name")) {
if (wpt) {
- wpt->shortname = xstrdup(attrv->value("name").toString().toUtf8().constData());
+ wpt->shortname = attrv->value("name").toString();
} else if (trk) {
- trk->rte_name = xstrdup(attrv->value("name").toString().toUtf8().constData());
+ trk->rte_name = attrv->value("name").toString();
}
}
if (wpt) {
if (attrv->hasAttribute("comment")) {
- wpt->notes = xstrdup(attrv->value("comment").toString().toUtf8().constData());
+ wpt->notes = attrv->value("comment").toString();
}
if (attrv->hasAttribute("alt")) {